<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class Category_model extends MY_model {
	public function __construct() {
		parent::__construct ( 'category' );
	}
	/**
	 * 创建数据表
	 */
	public function create() {
		$this->drop ();
		$sql = "CREATE TABLE `category` (
						`cid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '栏目ID',
						`cname` varchar(20) DEFAULT NULL COMMENT '栏目名称',
						`pcid` int(10) unsigned DEFAULT '0' COMMENT '父级栏目ID',
						`status` tinyint(1) unsigned DEFAULT '1' COMMENT '栏目状态',
						PRIMARY KEY (`cid`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='栏目管理表';";
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
	/**
	 * 删除数据表
	 */
	public function drop() {
		$sql = 'DROP TABLE IF EXISTS `category`;';
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
}